<?xml version="1.0" encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <ui:composition template="/template.xhtml">
        <ui:define name="title">
            <h:outputText value="#{bundleCliente.ListClienteTitle}"></h:outputText>
        </ui:define>
        <ui:define name="body">
            <h:form styleClass="jsfcrud_list_form">
                <h:panelGroup id="messagePanel" layout="block">
                    <p:messages />
                </h:panelGroup>
                
                <h:panelGroup rendered="#{clienteController.listaCliente != null }">
                
                    <p:dataTable value="#{clienteController.listaCliente}"
                                 var="itemCliente" paginator="true" rows="10"
                                 firstPageLinkLabel="#{bundlePrincipal.Primeiro}"
                                 lastPageLinkLabel="#{bundlePrincipal.Ultimo}"
                                 nextPageLinkLabel="#{bundlePrincipal.Proximo}"
                                 previousPageLinkLabel="#{bundlePrincipal.Anterior}"
                                 emptyMessage="Sem itens encontrados">
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundleCliente.ListClienteTitle_idCliente}"/>
                            </f:facet>
                            <h:outputText value="#{itemCliente.idCliente}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundleCliente.ListClienteTitle_nome}"/>
                            </f:facet>
                            <h:outputText value="#{itemCliente.nome}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundleCliente.ListClienteTitle_cpf}"/>
                            </f:facet>
                            <h:outputText value="#{itemCliente.cpf}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundleCliente.ListClienteTitle_rg}"/>
                            </f:facet>
                            <h:outputText value="#{itemCliente.rg}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundleCliente.ListClienteTitle_email}"/>
                            </f:facet>
                            <h:outputText value="#{itemCliente.email}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="#{bundleCliente.ListClienteTitle_telefone}"/>
                            </f:facet>
                            <h:outputText value="#{itemCliente.telefone}"/>
                        </p:column>
                        <p:column>
                            <f:facet name="header">
                                <h:outputText value="&nbsp;"/>
                            </f:facet>
                            <h:commandButton action="#{clienteController.prepareView}" value="#{bundleCliente.ListClienteViewLink}">
                                <f:setPropertyActionListener value="#{itemCliente}" target="#{clienteController.current}" />
                            </h:commandButton>
                            <h:outputText value=" "/>
                            <h:commandButton action="#{clienteController.prepareEdit}" value="#{bundleCliente.ListClienteEditLink}">
                                <f:setPropertyActionListener value="#{itemCliente}" target="#{clienteController.current}" />
                            </h:commandButton>
                            <h:outputText value=" "/>
                            <p:commandButton value="#{bundleCliente.ListClienteDestroyLink}" type="button" onclick="dialogo.show();">
                                <f:setPropertyActionListener value="#{itemCliente}" target="#{clienteController.current}" />
                            </p:commandButton>
                        </p:column>
                    </p:dataTable>
                </h:panelGroup>
                <br />
                <h:commandButton action="#{clienteController.prepareCreate}" value="#{bundleCliente.ListClienteCreateLink}"/>
                <br />
                <br />
                <h:commandButton value="#{bundleCliente.ListClienteIndexLink}" action="/restrito/index" immediate="true" />
            </h:form>
            <p:dialog widgetVar="dialogo" fixedCenter="true" height="150px" 
                      width="250px" modal="true" visible="block" id="diagConfirmacao"
                      header="Deseja excluir este item?">
                <h:form>
                    <h:panelGrid columns="2">
                        <p:commandButton value="SIM" action="#{clienteController.destroy}" ajax="false" oncomplete="dialogo.hide();"/>
                        <h:commandButton value="NÃO" onclick="dialogo.hide(); return false;" />
                    </h:panelGrid>
                </h:form>
            </p:dialog>
        </ui:define>
    </ui:composition>

</html>
